<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {include file="/layout/scriptload"}
    <title>添加复粉账号</title>
</head>
<body>
<div class="box">
    <!-- /.box-header -->
    <section class="content">
        <div class="box-body">
            <form role="form">
                <div class="form-group col-md-7">
                    <label>原始ID</label>
                    <input type="text" id="ghid" class="form-control"  placeholder="">
                </div>
                <div class="form-group col-md-7">
                    <label>总分类名称</label>
                    <select id="category_sum" class="form-control">
                        <option value="0" selected="selected">请选择...</option>
                        {volist name="category_sum" id="v"}
                        <option value="{$v.id}">{$v.categoryname}</option>
                        {/volist}
                    </select>
                </div>
                <div class="form-group col-md-7">
                    <label>子分类名称</label>
                    <select id="category_child" class="form-control">
                        <option value="">请选择...</option>
                    </select>
                </div>
                <div class="form-group col-md-7">
                    <label>账号池</label>
                    <select id="accountpool" class="form-control">
                        <option value="">请选择...</option>
                    </select>
                </div>
                <div class="form-group col-md-7">
                    <label>粉丝限制数量</label>
                    <input type="number" id="min"  class="form-control"  value="200">/十分钟<br>
                    <input type="number" id="hour" class="form-control"  value="400" style="margin-top: 10px;">/小时<br>
                    <input type="number" id="day"  class="form-control"  value="1000" style="margin-top: 10px;">/天<br>
                </div>
                <div class="form-group col-md-7">
                    <label>素材链接</label>
                    <select id="link_img_num" class="form-control">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                    </select>
                </div>
                <div class="form-group col-md-7" >
                    <div id="btn_save" class="btn pull-right" style="background: #18bc9c;color: #ffffff;">保存</div>
                </div>
            </form>
        </div>
    </section>
</div>
</body>
<script>
    $(function(){
        $("#category_sum").change(function () {
            var _id = $(this).val();
            $.ajax({
                type: 'post',
                cache: false,
                url: '{:url("admin/Replyfans/getCategoryChild")}',
                data: {cid: _id},
                success: function (data) {
                    if (data.code == "0") {
                        $("#category_child option").remove();
                        var html = '<option value="">请选择...</option>';
                        $("#category_child").append(html);
                        $.each(data.info, function (index, item) {
                            var html = '<option value="' + item.id + '">' + item.categoryname + '</option>';
                            $("#category_child").append(html);
                        });
                    }
                }
            });
        });
        $("#category_child").change(function () {
            var _id = $(this).val();
            $.ajax({
                type: 'post',
                cache: false,
                url: '{:url("admin/Replyfans/getShieldRule")}',
                data: {cid: _id},
                success: function (data) {
                    if (data.code == "0") {
                        $("#accountpool option").remove();
                        var html = '<option value="">请选择...</option>';
                        $("#accountpool").append(html);
                        $.each(data.info, function (index, item) {
                            var html = '<option value="' + item.id + '">' + item.poolname + '</option>';
                            $("#accountpool").append(html);
                        });
                    }
                }
            });
        });
        $('#btn_save').click(function(){
            var _ghid = $('#ghid').val();
            var _category_sum = $('#category_sum').val();
            var _category_child = $('#category_child').val();
            var _accountpool = $('#accountpool').val();
            var _min = $('#min').val();
            var _hour = $('#hour').val();
            var _day = $('#day').val();
            var _link_img_num = $('#link_img_num').val();
            if(_ghid == ''){
                layerAlert('ghid不能为空');
                return false;
            }
            if(_category_sum == ''){
                layerAlert('请选择总分类');
                return false;
            }
            if(_category_child == ''){
                layerAlert('请选择子分类');
                return false;
            }
            if(_accountpool == ''){
                layerAlert('请选择账号池');
                return false;
            }
            $.ajax({
                type:'post',
                cache: false,
                url:"{:url('replyfans/doAddAccount')}",
                data:{ghid:_ghid,category_sum:_category_sum,category_child:_category_child,accountpool:_accountpool,min:_min,hour:_hour,day:_day,link_img_num:_link_img_num},
                success:function(data){
                    if(data.code==0){
                        layerAlert(data.msg,function(){
                            parent.relist();
                            layerParentClose();
                        });
                    }else{
                        layerAlert(data.msg);
                    }
                }
            })
        })
    })
</script>
</html>